package com.example.day09_7_9_2.base;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity implements BaseView {

    public P mPersenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        mPersenter = initPresenter();
        if (mPersenter != null){
            mPersenter.bindView(this);
        }
        initView();
    }

    protected abstract P initPresenter();

    protected abstract View getLayout() ;

    protected abstract void initView() ;
    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPersenter.onDestory();
        mPersenter = null;
    }
}
